package cn.edu.hhtc.stsystem.security.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.edu.hhtc.hibernate.utils.HibernateDao;
import cn.edu.hhtc.stsystem.Exception.DaoException;
import cn.edu.hhtc.stsystem.security.domain.SysResources;

/**
 * 系统资源dao.
 * 
 * @author linyueqin
 * 
 */
@Repository
public class SysResourcesDao extends HibernateDao<SysResources, Long> {

	/**
	 * 通过权限名称查询权限所能访问的资源.
	 * 
	 * @param authorityName
	 * @return
	 * @throws DaoException
	 */
	@SuppressWarnings("unchecked")
	public List<String> queryResourceValueByAuthorityName(String authorityName) throws DaoException {

		return super
				.createQuery(
						"select t1.value from SysResources t1, SysAuthorityResource t2, SysAuthorities t3 where t1.id = t2.pkId.resourceId and t2.pkId.authorityId = t3.id and t3.name = ?",
						authorityName).list();
	}
}
